<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<!--<script type="text/javascript">
	$(document).ready(function(){
		$("button").click(function(){
			$.ajax({
				type:"get",
				url:"/weba/ajaxServlet",
				async:true,
				success:function(data){
					var dataObj=jQuery.parseJSON(data);
					for(attr in dataObj){
						alert(dataObj[attr]);
					}
				}
			});
		})
	})
</script>-->
</head>
<body>
	<p></p>
	<button type="button" onclick="loadData()">点击</button>
	
	<script type="text/javascript">
		function loadData(){
			var xmlRequest="";
			if(window.XMLHttpRequest){
				xmlRequest=new XMLHttpRequest();
			}
			else{
				xmlRequest=new ActiveXObject();
			}
			//0-初始化未完成  1-服务器建立连接  2-接受请求 3-正在处理请求 4-请求完成，响应就绪 
			xmlRequest.onreadystatechange=function(){
				if(xmlRequest.readyState==1){
					console.log("初始化。。。。");
				}
				if(xmlRequest.readyState==4&xmlRequest.status==200){
					alert(xmlRequest.responseText);
					$("p").html(xmlRequest.responseText);
				}
			}
			
			xmlRequest.open("GET","http://localhost:8080/weba/ajaxServlet",true);
			xmlRequest.send();
		}
	</script>
</body>
</html>